# 1. 打开register.html
# 2. 填写主页面 页面信息
# 3. 填写注册A 页面信息
# 4. 填写注册B 页面信息
from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep

driver = webdriver.Firefox()
driver.maximize_window()
driver.get('file:///D:/nsd2404/html/register.html')

# 填写主页面 页面信息
driver.find_element(By.CSS_SELECTOR, '#user').send_keys('admin')
driver.find_element(By.CSS_SELECTOR, '#password').send_keys('123456')
driver.find_element(By.CSS_SELECTOR, '#tel').send_keys('18812348891')
driver.find_element(By.CSS_SELECTOR, '#email').send_keys('123@163.com')

sleep(3)
# 切换到A页面  可以提供id、name、frame_element
# driver.switch_to.frame('idframe1')
# 定位到要进入去frame的元素
f = driver.find_element(By.CSS_SELECTOR, '[src="registerA.html"]')
driver.switch_to.frame(f)
# 往注册A页面 输入信息
driver.find_element(By.CSS_SELECTOR, '#userA').send_keys('admin')
driver.find_element(By.CSS_SELECTOR, '#passwordA').send_keys('123456')
driver.find_element(By.CSS_SELECTOR, '#telA').send_keys('18812348891')
driver.find_element(By.CSS_SELECTOR, '#emailA').send_keys('123@163.com')

# 切换回主页面
driver.switch_to.default_content()
# 切换到B页面
driver.switch_to.frame('myframe2')
# 往B页面 输入信息
driver.find_element(By.CSS_SELECTOR, '#userB').send_keys('admin')
driver.find_element(By.CSS_SELECTOR, '#passwordB').send_keys('123456')
driver.find_element(By.CSS_SELECTOR, '#telB').send_keys('18812348891')
driver.find_element(By.CSS_SELECTOR, '#emailB').send_keys('123@163.com')


sleep(3)
driver.quit()